<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
	body,html{
		margin: 0 auto;
		height:100%;
		width:100%;
		overflow:hidden;
	}
</style>
</head>
<body>
<div id="add_commodity_main" style="width:100%;height:100%;overflow: auto;" class="divfrist">
			<DIV id="" style="width:100%;height:0.7%;overflow:hidden;"></DIV>
			<DIV id="" style="width:100%;height:98.6%;">
					<DIV id="" class="" style="float:left;width:0.4%;height:100%;overflow:hidden;"></DIV>
					<DIV id="" class="" style="float:left;width:20%;height:100%;">
							<DIV id="" class="allborder" style="width:100%;height:100%;max-height:100%;max-width:100%;overflow:hidden;">
							   <!--内容区 -->
							   				<div style="width:100%;height:100%;">
								   				<div id="add_commodtityTree_panel" title="类型管理" data-options="iconCls:'icon774',tools:'#add_commodtityTree_tb',fit:true,border:false," style="width:100%;">																
															    	<ul id="add_commodtityTree" class="ztree"></ul>										    																							 
												</div>
											 </div>
												<div id="add_commodtityTree_tb" style="display:none;">
															 <a href="javascript:void(0)" class="icon-add" onclick="window.Commodity.addCommodityType()"></a>
	       													 <a href="javascript:void(0)" class="icon-edit" onclick="window.Commodity.addCommodityType()"></a>
												</div>
										
												
							   <!--内容区 -->
							</DIV>
					</DIV>
					<DIV id="" class="" style="float:left;width:0.4%;height:100%;overflow:hidden;"></DIV>
					<DIV id="" class="" style="float:left;width:78.8%;height:100%;">
							<DIV id="" class="allborder" style="width:100%;height:100%;max-height:100%;max-width:100%;">
								<!-- 内容区 -->
										 	<div style="width:100%;height:100%;">		
													 <table  id="CommodityTable" border="false"></table>
											</div>
											 <div id="Commodity_tb" style="overflow: hidden; padding-left: 10px; padding-top: 5px;padding-bottom: 5px;">
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon-add',plain:true" onclick="window.Commodity.addCommodity()">增加货品</a>||	
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon-edit',plain:true" onclick="window.Commodity.addCommodity()">编辑货品</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon-no',plain:true" onclick="window.Commodity.addCommodity()">删除货品</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon14',plain:true" onclick="window.Commodity.addCommodity()">导入货品</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon45',plain:true" onclick="window.Commodity.addCommodity()">导出货品</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon247',plain:true" onclick="window.Commodity.addCommodity()">打印</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon248',plain:true" onclick="window.Commodity.addCommodity()">预览</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon31',plain:true" onclick="window.Commodity.addCommodity()">隐藏零库存</a>||
												 <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon31',plain:true" onclick="window.Commodity.addCommodity()">隐藏零库存</a>||
												 <br>
												 输入名称或者编号:<input type="text" id="userNameNuber"> <a href="javascript:void(0);" class="easyui-linkbutton"   data-options="iconCls:'icon486',plain:true" onclick="window.User.selectUser()">查询用户</a>||	
											</div>	
								<!-- 内容区 -->
							</DIV>
					</DIV>
					<DIV id="" class="" style="float:left;width:0.37%;height:100%;overflow:hidden;"></DIV>
			</DIV>
			<DIV id="" class="div_bottom"></DIV>
	</div>
</body>
<script type="text/javascript">
(function(){	
	
	//增加货品
	function addCommodity(){
		
		if($("#Commodity_addCommodity").length>0){
			$("#Commodity_addCommodity").window("open");
		}
		$('<div id="Commodity_addCommodity"></div>').window({
		    title: '增加货品', 		
		    iconCls:'icon-add', 
		    width:getWW().w,   
		    height:getWW().h,   
		    resizable:true,
		    closed: true,   
		    draggable:false,
		    modal: true,
		    content:'aaa',
		    onClose:function(){
				$("#Commodity_addCommodity").window("destroy",true);
				
		    }
		});
		$("#Commodity_addCommodity").window("open");
		
	};
	//创建货品table
	function createCommodityTable(){
			$('#CommodityTable').datagrid({
				fit: true,
				toolbar:"#Commodity_tb",
				singleSelect:false,
				rownumbers: true,
				animate:true,
				striped: true,
				loadMsg:'正在加载数据',
				url: "${pageContext.request.contextPath}/jxc/basicCommodityAction!getbasicCommodity.action",
				collapsible:true,
				idField:'sysCommodity_id',
				fitColumns:true,
				columns:[[
				    {field:'sysCommodity_id',checkbox:true,width:50},	
			  		{field:'sysCommodity_name',title:'货品名称',width:120},
			  		{field:'sysCommodity_state',title:'货品状态',formatter : function(value, row, index){
						if(row.sysCommodity_state=="0"){
							return  '<font color="red">禁用</font>';
						}
						if(row.sysCommodity_state=="1"){
							return  '<font color="green">启用</font>';
						}
						return "";
						},width:120},
			  		{field:'sysCommodity_note',title:'货品描述',width:120},
			  		{field:'sysCommodity_createDate',title:'创建时间',width:120}
			  		]],
					pagination:true
				});
	};
	function addCommodityType(){
		
		if($("#Commodity_addCommodityType").length>0){
			$("#Commodity_addCommodityType").window("open");
		}
		$('<div id="Commodity_addCommodityType"></div>').window({
		    title: '增加类型', 		
		    iconCls:'icon-add', 
		    width:getWW().w,   
		    height:getWW().h, 
		    maximizable:false,
		    resizable:false,
		    closed: true,   
		    draggable:false,
		    modal: true,
		    content:$('<div style="width:100%;height:100%;"></div>').load("${pageContext.request.contextPath}/html/jxc/add_commodityType.jsp"),
		    onClose:function(){
				$("#Commodity_addCommodityType").window("destroy",true);
				createCommodityTreePanel();		
		    }
		});
		$("#Commodity_addCommodityType").window("open");
		
	};
	//双击树改变类型选择
	function onClick(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("add_commodtityTree");
		nodes = zTree.getSelectedNodes();
		//$("#pname").val(nodes[0].name);
		//$("#pId").val(nodes[0].id);
		//$("#comTypeId").val(nodes[0].comTypeId);
		
	}
	//创建树
	function createUpdateTree(){
		
		var setting = {
				view: {
					dblClickExpand: false
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				callback: {
					onClick: onClick
				}
			};
		$.ajax({
			   type: "POST",
			   url: "${pageContext.request.contextPath}/jxc/commodtityTypeAction!getCommodtityTypeTree.action",
			   data:{areaId:"${areaId}"},
			   dataType:'json',
			   success: function(msg){
				   try{
					   var node = new Object();
					   node.uuid=0;
					   node.id=1;
					   node.pid=0;
					   node.name="所有类型";
					   node.open=true;
					   msg.push(node);
					   $.fn.zTree.init($("#add_commodtityTree"), setting, msg);  	   
					   
				   }catch(e){
					   alert(e);
				   }
				 
			   }
		});	
	}
	//创建树的panel
	function createCommodityTreePanel(){
		$('#add_commodtityTree_panel').panel({   
			  fit:true,
		});
	}
	//注册所有事件
	window["Commodity"]={};
	window["Commodity"]["addCommodity"]=addCommodity;
	window["Commodity"]["addCommodityType"]=addCommodityType;
	$(function(){	
		$.parser.parse('#add_commodity_main'); 
		createUpdateTree();
		createCommodityTable();
		createCommodityTreePanel();
		
	});
})();
</script>
</html>